package com.study.sxc.Dao;

import com.study.sxc.Entity.MachineType;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface IMachineTypeDao {
    @Select({
        "<script>",
        "SELECT type_id AS typeId, type_name AS typeName, specifications, hourly_rate AS hourlyRate",
        "FROM Machine_Types",
        "WHERE type_id IN",
        "<foreach collection='list' item='id' open='(' separator=',' close=')'>",
        "#{id}",
        "</foreach>",
        "</script>"
    })
    List<MachineType> getMachineTypes(List<Integer> ids);

    @Insert("INSERT INTO Machine_Types (type_name, specifications, hourly_rate) VALUES (#{typeName}, #{specifications}, #{hourlyRate})")
    @Options(useGeneratedKeys = true, keyProperty = "typeId")
    int addMachineType(MachineType machineType);

    @Update("UPDATE Machine_Types SET type_name = #{typeName}, specifications = #{specifications}, hourly_rate = #{hourlyRate} WHERE type_id = #{typeId}")
    int updateMachineType(MachineType machineType);

    @Delete("DELETE FROM Machine_Types WHERE type_id = #{id}")
    int deleteMachineType(Integer id);

    @Select("SELECT type_id AS typeId, type_name AS typeName, specifications, hourly_rate AS hourlyRate FROM Machine_Types WHERE type_id = #{id}")
    MachineType getMachineTypeById(Integer id);

    @Select("SELECT type_id AS typeId, type_name AS typeName, specifications, hourly_rate AS hourlyRate FROM Machine_Types")
    List<MachineType> getAllMachineTypes();
} 